<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js"></script>
<script type="text/javascript">
function updatecat(id){
	var text = document.getElementById('name_'+id).value;
	url = "<?php echo base_url();?>"+"/addmincont/updatecat/";
	var data ={'ref':id,'name':text};
	$.ajax({
		type : 'POST',
		url: url,
		data:data,
		dataType:'html',
		success: function(result){
			if(result==1){
				alert('Update Product Successfull');
				window.location.reload(true);
			}else{
				alert('Error connect to DB');
			}
		}
	});//end ajax	
}
function deletecat(id){
	var text = document.getElementById('name_'+id).value;
	var r=confirm("Are you sure Delete Categories! "+text);
	if (r==true){
		url = "<?php echo base_url()?>/addmincont/delcatesub/";
		var data ={ref:id};
		$.ajax({
			type : 'POST',
			url: url,
			data:data,
			dataType:'html',
			success: function(result){
				if(result==1){
					alert('Delete Product Successfull');
					window.location.reload(true);
				}else{
					alert('Error connect to DB');
				}
			}
		});//end ajax
	}else{
		return false;
	}	
}
</script>
<table>
<?php 
$count_cat = count($cattype);
for ($i = 0; $i < $count_cat; $i++){
	?>
	<tr>
		<td>
			<input type="text" value="<?php echo $cattype[$i]['cat_type_name']; ?>" name="name_<?php echo $cattype[$i]['cat_type_id']; ?>" id="name_<?php echo $cattype[$i]['cat_type_id']; ?>">
		</td>
		<td>
			<input type="button" value="Update" name="update_<?php echo $cattype[$i]['cat_type_id']; ?>" id="update_<?php echo $cattype[$i]['cat_type_id']; ?>" onclick="updatecat(<?php echo $cattype[$i]['cat_type_id']; ?>);">
		</td>
		<td>
			<input type="button" value="Delete" name="delete_<?php echo $cattype[$i]['cat_type_id']; ?>" id="delete_<?php echo $cattype[$i]['cat_type_id']; ?>" onclick="deletecat(<?php echo $cattype[$i]['cat_type_id']; ?>);">
		</td>
	</tr>
	<?php 
}
?>
</table>